﻿using System;

namespace StupidGrid.Example
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            btn_view.Click += btn_view_Click;
        }

        void btn_view_Click(object sender, EventArgs e)
        {
            // use RetrieveUserControls to get a list of all the user controls that the user
            // has created up until this point
            //
            // you must specify the usercontrol type between the angle brackets
            // i'm not a fan of this, but I haven't thought of a better way yet
            var allAddresses = stupidgrid_address.RetrieveUserControls<address>();

            lit_results.Text = "";
            foreach (var address in allAddresses)
            {
                lit_results.Text += "<p>Address: " + address.Address + ", " + address.City + ", " + address.State + "</p>";
            }
        }
    }
}
